#include "fill_vector.h"

void fill_vector(std::istream &ist, std::vector<int> &v, char terminator)
{
    ist.exceptions(std::ios_base::badbit);
    for (int i = 0; ist >> i;)
    {
        v.push_back(i);
    }
    if (ist.eof())
        return;
    ist.clear();
    char c;
    ist >> c;
    if (c != terminator)
    {
        ist.unget();
        ist.clear(std::ios_base::failbit);
    }
}